package com.ideal.frame.sys.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ideal.frame.entity.AutoModel;
import lombok.Data;

import javax.persistence.*;

/**
 * @author: zhangdelei
 * @date: 2021/9/14-10:14 上午
 * @Description:
 **/
@Data
@Entity
@Table(name = "t_sys_level_menu")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class SysLevelMenu extends AutoModel {
    /**
     * 节点级别
     */
    private long level;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "menu_id")
    private SysMenu sysMenu;

    private SysLevelMenu(Builder builder) {
        level = builder.level;
        sysMenu = builder.sysMenu;
    }


    public static Builder builder() {
        return new Builder();
    }

    public static Builder copy(SysLevelMenu src) {
        Builder builder = new Builder();
        builder.level = src.level;
        builder.sysMenu = src.sysMenu;
        return builder;
    }

    public static class Builder {
        private long level;
        private SysMenu sysMenu;

        private Builder() {
        }

        public Builder level(long level) {
            this.level = level;
            return this;
        }

        public Builder sysMenu(SysMenu sysMenu) {
            this.sysMenu = sysMenu;
            return this;
        }

        public SysLevelMenu build() {
            return new SysLevelMenu(this);
        }
    }
}
